From 9f1687725292f90c8bc9e7266f062b2e7ec029df Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 28 Jul 2011 15:40:54 +0100 Subject: [PATCH] hvmloader: Enable SCI in QEMU has it disabled. When booting a Windows guest, the OS report an issue with the ACPI (in a BSOD). The exact issue is "SCI_EN never becomes set in PM1 Control Register." (quoted from WinDbg help). So this patch enables the flags SCI_EN if it is not yet enabled. Reported-by: Tobias Geiger Signed-off-by: Anthony PERARD Signed-off-by: Keir Fraser --- tools/firmware/hvmloader/acpi/acpi2_0.h | 4 ++++ tools/firmware/hvmloader/acpi/static_tables.c | 1 - tools/firmware/hvmloader/hvmloader.c | 22 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/tools/firmware/hvmloader/acpi/acpi2_0.h b/tools/firmware/hvmloader/acpi/acpi2_0.h index 324cd43e38..dcc362ad5d 100644 --- a/tools/firmware/hvmloader/acpi/acpi2_0.h +++ b/tools/firmware/hvmloader/acpi/acpi2_0.h @@ -20,6 +20,7 @@ #include #include +#include #define ASCII32(a,b,c,d) \ (((a) << 0) | ((b) << 8) | ((c) << 16) | ((d) << 24)) @@ -252,6 +253,9 @@ struct acpi_20_fadt { #define ACPI_CPU_SW_SLP (1 << 13) #define ACPI_USE_PLATFORM_CLOCK (1 << 15) +/* PM1 Control Register Bits */ +#define ACPI_PM1C_SCI_EN (1 << 0) + /* * Firmware ACPI Control Structure (FACS). */ diff --git a/tools/firmware/hvmloader/acpi/static_tables.c b/tools/firmware/hvmloader/acpi/static_tables.c index cf4b8dc825..da61304f46 100644 --- a/tools/firmware/hvmloader/acpi/static_tables.c +++ b/tools/firmware/hvmloader/acpi/static_tables.c @@ -18,7 +18,6 @@ #include "acpi2_0.h" #include "../config.h" -#include /* * Firmware ACPI Control Structure (FACS). diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c index 5e7d128307..4129670fc7 100644 --- a/tools/firmware/hvmloader/hvmloader.c +++ b/tools/firmware/hvmloader/hvmloader.c @@ -26,6 +26,7 @@ #include "pci_regs.h" #include "option_rom.h" #include "apic_regs.h" +#include "acpi/acpi2_0.h" #include #include @@ -379,6 +380,25 @@ static const struct bios_config *detect_bios(void) return NULL; } +static void acpi_enable_sci(void) +{ + uint8_t pm1a_cnt_val; + +#define PIIX4_SMI_CMD_IOPORT 0xb2 +#define PIIX4_ACPI_ENABLE 0xf1 + + /* + * PIIX4 emulation in QEMU has SCI_EN=0 by default. We have no legacy + * SMM implementation, so give ACPI control to the OSPM immediately. + */ + pm1a_cnt_val = inb(ACPI_PM1A_CNT_BLK_ADDRESS_V1); + if ( !(pm1a_cnt_val & ACPI_PM1C_SCI_EN) ) + outb(PIIX4_SMI_CMD_IOPORT, PIIX4_ACPI_ENABLE); + + pm1a_cnt_val = inb(ACPI_PM1A_CNT_BLK_ADDRESS_V1); + BUG_ON(!(pm1a_cnt_val & ACPI_PM1C_SCI_EN)); +} + int main(void) { const struct bios_config *bios; @@ -481,6 +501,8 @@ int main(void) bios->acpi_build_tables(); } + acpi_enable_sci(); + hypercall_hvm_op(HVMOP_set_param, &p); } -- 2.30.2